package com.mashibing.tank.Strategy;

import com.mashibing.tank.pojo.Bullet;
import com.mashibing.tank.pojo.Tank;

/**
 * @ClassName DefaultFireStrategy
 * @Description TODO
 * @Author zhangjunhao
 * @DATE 2023/8/29 9:58
 */
public class DefaultFireStrategy implements FireStrategy  {


    @Override
    public void fire(Tank tank) {

        //子弹打出的位置
        int bX = tank.getX() + tank.getWIDTH() / 2 - Bullet.getWIDTH() / 2;
        int bY = tank.getY() + tank.getHEIGHT() / 2 - Bullet.getHEIGHT() / 2;

        //窗口中放入子弹的容器  直接把这里放到Bullet中的构造方法实现
        tank.getTankFrame().gameFactory.createBullet(bX, bY, tank.getDir(), tank.getGroup(), tank.getTankFrame());

    }
}
